package day8

import org.apache.spark.sql.SparkSession

object Test4_kaiChuang {
  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession.builder().master("local[*]").appName("yy").getOrCreate()
    import spark.implicits._

    var df = List((1, "zs", true, 1, 15000), (2, "ls", false, 2, 18000), (3, "ww", false, 2, 14000), (4, "zl", false, 1, 18000),
      (5, "win7", false, 1, 15000), (6, "哈哈", false, 1, 12000)).toDF("id", "name", "sex", "dept", "salary")

    df.createTempView("t_emp")

    spark.sql(
      """
        |
        |
        |     select id,name,sex,dept,salary,
        |           row_number()
        |           over(order by salary) x1
        |     from t_emp
        |
        |
        |""".stripMargin).show()

    spark.stop()
  }
}
